﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace WcfCore
{
    public static class WcfProcessHelper
    {
        public static void StartChildProcessAndWaitForExit(string exePath, string commandline)
        {
            WcfLogger.Log(string.Format("Starting {0} with commandline {1}:", exePath, commandline));

            ProcessStartInfo psi = new ProcessStartInfo(exePath, commandline);
            psi.UseShellExecute = false;
            psi.RedirectStandardOutput = true;

            Process pskill = new Process();
            pskill.StartInfo = psi;
            pskill.Start();

            string output = pskill.StandardOutput.ReadToEnd();
            pskill.WaitForExit();
            WcfLogger.Log(output);
        }
    }
}
